﻿<%@ Page Title="报警台" Language="C#" MasterPageFile="~/Web/Main.Master" AutoEventWireup="true" CodeBehind="WarningPage.aspx.cs" Inherits="BOMS.WebUI.Web.Warning.WarningPage" %>
<%@ Import Namespace="BOMS.WebUI.Web" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<script type="text/javascript" src="/Js/Jquery.js"></script>
<script type="text/javascript" src="/Js/Dialog.js"></script>
<script type ="text/javascript">
$(document).ready(function () {
    setInterval("startRequest()",'<%=Common.RefreshIntev%>');
});
function startRequest() {

    /*    $("#wd").load(location.href + " #wd>*"
        , "" + Math.random() + ""
        , function () { checkRowsForPlay(); }
    ); */
    $("#<%=btnRefresh.ClientID %>")[0].click(); //刷新
    setTimeout("checkRowsForPlay()", 1000);
    CollectGarbage();
    setTimeout("CollectGarbage();", 1);
   
}
function checkRowsForPlay() {
    if ($("#wd tr").length > 2) {
        var url = document.location.href;
        url = url.substr(0, url.length - 29) + '/Alarm/music/alarm.wav';
        //alert(url);
        play_click(this, url);
    }
}

function play_click(sef, url) {

    var div = document.getElementById('div1');
    div.innerHTML = '<embed src="' + url + '" autostart="true" hidden="true"></embed>';
    var emb = document.getElementsByTagName('EMBED')[0];
    if (emb) {
        /* 这里可以写成一个判断 wav 文件是否已加载完毕，以下采用setTimeout模拟一下 */
        div = document.getElementById('div2');
        div.innerHTML = 'loading: ' + emb.src;
        sef.disabled = true;
        setTimeout(function () { div.innerHTML = ''; }, 1000);
    }
}

function zOpen(wid) {
    var diag = new Dialog("Diag2");
    diag.Width = 750;
    diag.Height = 345;
    diag.Title = "报警信息处理窗口";
    diag.URL = "Web/Warning/WarningProcess.aspx?warningid=" + wid + "&rdm=" + Math.random();
    diag.OKEvent = callback;    //点击确定后调用的方法
    diag.CancelEvent = callback;
    diag.show();
}
function callback(obj) {
    //debugger;
    if (obj.DialogArguments["returnValue"] == "true") {
    $("#wd").load(location.href + " #wd>*", "" + Math.random() + "");
    } else {
        // do nothing.
    }
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div id="div1" style="display:none"></div>
<div id="div2" style="display:none"></div>
<table class="usertableborder" cellspacing="1" cellpadding="3" width="96%" align="center" border="0" id="wd">
    <tr>
        <th colspan="7">系统报警台</th>
    </tr>
    <tr>
        <td class="usertablerow3">现场主机名称</td>
        <td class="usertablerow3">IP地址</td>
        <td class="usertablerow3">电池组</td>
        <td class="usertablerow3">电池编号</td>
        <td class="usertablerow3">报警类型</td>
        <td class="usertablerow3">报警时间</td>
        <td class="usertablerow3">操作</td>
    </tr>
    <asp:UpdatePanel ID="udp1" runat="server">
        <ContentTemplate>
         <asp:Repeater runat="server" ID="Repeater1">
            <ItemTemplate>
                <tr class="usertablerow2">
                    <td align="center"><%#Eval("HostName") %></td>
                    <td align="center"><%#Eval("IP") %></td>
                    <td align="center"><%#Eval("BatteryGroup") %></td>
                    <td align="center"><Asp:Literal runat="server" ID="ltrBatteryID" ></Asp:Literal></td>
                    <td align="center"><asp:Literal runat="server" ID="ltrWarningDesc" ></asp:Literal></td>
                    <td align="center"><%#Eval("WarningTime") %></td>
                    <td align="center"><a onclick="javescript:zOpen(<%#Eval("ID")%>)">处理</a></td>
                </tr>
            </ItemTemplate>            
        </asp:Repeater>
        <asp:Button runat="server" ID="btnRefresh" Text="" style="display:none;" OnClick="btnRefresh_Click" />
        </ContentTemplate>
    </asp:UpdatePanel>
</table>
</asp:Content>
